import java.util.HashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 17655
 * Date: 2025-06-11
 * Time: 21:34
 */
public class test5 {
    public int[] twoSum(int[] nums, int target) {
        int n = nums.length;
        int[] ret = new int[2];
        // key是nums[i]的值，value是i下标
        Map<Integer,Integer> hash = new HashMap<Integer,Integer>();
        for(int i=0;i<n;i++){
            if(hash.containsKey(target-nums[i])){
                return new int[]{hash.get(target-nums[i]),i};
            }
            hash.put(nums[i],i);
        }
        return new int[0];
    }
}
